image: Add /sysroot as a toplevel bind mount to the real root
authorColin Walters <walters@verbum.org>
Thu, 27 Oct 2011 20:59:01 +0000 (16:59 -0400)
committerColin Walters <walters@verbum.org>
Thu, 27 Oct 2011 20:59:01 +0000 (16:59 -0400)
This allows tools to see and operate on the "real" root conveniently;
for example, ostree clearly needs to operate on /ostree/repo.

parallel-debian/gnomeos-make-image.sh
parallel-debian/gnomeos-run.sh
parallel-debian/ostree_switch_root.c

index a1591431bc26e174822e4acde1d86d0989143291..de3c30a32f534a8200e0a7d265cbd50746ac4b77 100755 (executable)
@@ -144,8 +144,10 @@ if ! test -d ${OBJ}; then
         rm ostree/gnomeos-origin/debian-setup.sh
         (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Run debian-setup.sh' --repo=../repo --from-stdin)
 
-        cp -p ${SRCDIR}/chroot_break ostree/gnomeos-origin/sbin/chroot_break
-        (cd ostree/gnomeos-origin; $OSTREE commit -s 'Add chroot_break' --repo=../repo --add=sbin/chroot_break)
+        # This is the name for the real rootfs, not the chroot
+        (cd ostree/gnomeos-origin;
+            mkdir sysroot;
+            $OSTREE commit -s 'Add sysroot' --repo=../repo --add=sysroot)
 
         (cd ostree;
             rev=$($OSTREE rev-parse --repo=repo master)
index cb4179129633df7e71858591732e4def968c3896..9d17ba29a6c4dfe78180dbb9f948d2c98b2832a1 100755 (executable)
@@ -45,4 +45,4 @@ fi
 kv=`uname -r`
 kernel=/boot/vmlinuz-${kv}
 
-exec qemu-kvm -kernel ${kernel} -initrd gnomeos-initrd.img -hda gnomeos-fs.img -append "root=/dev/sda ostree=current"
+exec qemu-kvm -kernel ${kernel} -initrd gnomeos-initrd.img -hda gnomeos-fs.img -append "root=/dev/sda ostree=current $1"
index fb750f2d28324d7d06036e1b691a4826f5347adc..d3e82b14ed0eef6804d14d3f1e9be244165d698d 100644 (file)
@@ -219,6 +219,12 @@ static int switchroot(const char *newroot, const char *subroot)
                }
        }
 
+       snprintf(destpath, sizeof(destpath), "%s/sysroot", subroot_path);
+       if (mount(newroot, destpath, NULL, MS_BIND, NULL) < 0) {
+               perrorv("Failed bind mount sysroot");
+               return -1;
+       }
+
        if (chdir(newroot)) {
                perrorv("failed to change directory to %s", newroot);
                return -1;